package com.click369.crm.service.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.click369.crm.mapper.CFunctionMapper;
import com.click369.crm.pojo.CFunction;
import com.click369.crm.service.FunctionService;
import com.github.pagehelper.PageInfo;

@Service
public class FunctionServiceImpl implements FunctionService{
	
	@Autowired
	private CFunctionMapper functionMapper;
	
	//添加
	@Override
	public void save(CFunction function) {
		functionMapper.insert(function);
	}
	//根据id删除
	@Override
	public void delete(Integer id) {
		functionMapper.deleteByPrimaryKey(id);
	}
	//修改
	@Override
	public void update(CFunction function) {
		functionMapper.updateByPrimaryKey(function);
	}
	//查询所有分页
	@Override
	public PageInfo<CFunction> select(Integer page, Integer rows, CFunction function) {
		return null;
	}
	//根据id查询
	@Override
	public CFunction getById(Integer id) {
		return functionMapper.selectByPrimaryKey(id);
	}
	@Override
	public List<HashMap> getNodesByPid(Integer pid) {
		return functionMapper.getNodesByPid(pid);
	}
	@Override
	public List<HashMap> getNodesByRid(Integer rid) {
		return functionMapper.getNodesByRid(rid);
	}
	@Override
	public void editRoleFunction(Integer rid, Integer[] fids) {
		//先删除旧的id
		functionMapper.deleteAllFunctionByRid(rid);
		//增加新的id
		functionMapper.addFunctionByRid(rid,fids);
	}
}
